<include file="Public:header" />
<div class="container">
  <div class="mainbody">

    <div class="rig_lm03">
      
      <div class="detail-tab">
          <form name="form1"  enctype="multipart/form-data" method="post" action="" role="form" >
          <div class="form-group">
            <label for="name">姓名<i>*</i></label>
            <input type="text" name="name" class="searcheTxt"  id="name" placeholder="" <notempty name="data.name">readonly="readonly"</notempty> value="{$data.name}">
          </div>
          <div class="form-group">
            <label for="img">头像</label>
                       <input type=button value="&#x1F4F7;" id="chooseImage">
                        <input type=button value="&#x1F4F3;" id="previewImage">
                         <input type=button value="&#x1F4F1;" id="uploadImage">
                          <input type=button value="&#x1F4F0;" id="downloadImage">
           <img src="weixin://resourceid/f81b6668f67b22c9cc659436083db9f4">
			<img src="" id="imgs">
            <p class="help-block formRemind">个人头像尺寸110*160，集体图片尺寸210*160的jpg格式的图片。</p>
          </div>
       <!--  <div class="form-group">
            <label for="u_type">类型</label>
            <input name="u_type" type="radio" value="1" checked="checked" />个人&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="u_type" type="radio" value="2" <eq name="data.u_type" value="2">checked="checked"</eq> />集体
          </div>-->
          <div class="form-group">
            <label for="info">简介</label>
            <textarea name="info" id="info" class="inputTextarea" style="height:100px;">{$data.info|strip_tags}</textarea>
          </div>
          <div class="form-group">
            <label for="detail">详情</label>
            <textarea name="detail" id="detail" class="inputTextarea" style="height:240px;">{$data.detail|strip_tags}</textarea>
          </div>
          
          <div class="form-group ">
            <label for="IbtnEnter"></label>
            <button type="button"  id="IbtnEnter" class="btn btn-primary " onClick="tijiao();"><span class="glyphicon glyphicon-floppy-saved"></span> 保 存 </button>
          </div>

          <input type="hidden" name="activityId" value="{$activityId}">
          </form>
      </div>
    </div>
  </div>
</div>



<include file="Public:footer" /> 
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
wx.config({
	 // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    debug: false,
    appId: '<?php echo $signPackage["appId"];?>',
    timestamp: '<?php echo $signPackage["timestamp"];?>',
    nonceStr: '<?php echo $signPackage["nonceStr"];?>',
    signature: '<?php echo $signPackage["signature"];?>',
    jsApiList: ['chooseImage', 'uploadImage', 'downloadImage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
});


  document.querySelector('#chooseImage').onclick = function () {
    wx.chooseImage({
      success: function (res) {
			
			if(res.localIds.length == 1) {
				upload();
			}
           
      }
    });
  };



  // 5.3 上传图片
  document.querySelector('#uploadImage').onclick = function () {
    if (images.localId.length == 0) {
      alert('请先使用 chooseImage 接口选择图片');
      return;
    }
    var i = 0, length = images.localId.length;
    images.serverId = [];
    function upload() {
	alert(1);
      wx.uploadImage({
        localId: images.localId[i],
        success: function (res) {
		alert(res.serverId);
		$.getJSON('__URL__/tt', {serverid:res.serverId}, function(json){			
			alert(json);
		})
          i++;
          alert('已上传：' + i + '/' + length);
          images.serverId.push(res.serverId);
          if (i < length) {
            upload();
          }
        },
        fail: function (res) {
          alert(JSON.stringify(res));
        }
      });
    }
    upload();
  };

  // 5.4 下载图片
  document.querySelector('#downloadImage').onclick = function () {
    if (images.serverId.length === 0) {
      alert('请先使用 uploadImage 上传图片');
      return;
    }
    var i = 0, length = images.serverId.length;
    images.localId = [];
	alert(images.serverId[i]);
    function download() {
      wx.downloadImage({
        serverId: images.serverId[i],
        success: function (res) {
          i++;
          alert('已下载：' + i + '/' + length);
		  alert(res.localId);
          images.localId.push(res.localId);
          if (i < length) {
            download();
          }
        }
      });
    }
    download();
  };

</script>